package com.dz.Incubator.controller;

import com.dz.Incubator.dto.ManagerLoginDto;
import com.dz.Incubator.entity.InvokeResult;
import com.dz.Incubator.entity.SysManagerEntity;
import com.dz.Incubator.service.SysManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/sysManager")
public class SysManagerContorller {

    @Autowired
    private SysManagerService sysManagerService;

    @PostMapping("/login")
    public InvokeResult login(@RequestBody ManagerLoginDto dto) {
        SysManagerEntity entity = sysManagerService.login(dto.getUsername(), dto.getPassword());
        return entity == null ? InvokeResult.failure("用户名密码错误") : InvokeResult.success("登录成功");
    }
}
